<template>
  <div class="ke-opencourse-comment">
    <div class="none-comment" v-if="(commentList.length === 0)">该课程还没有评论</div>
    <ul class="wrapper infinite-list" style="overflow:auto" v-else>
      <li
        v-for="(item, index) in commentList"
        :key="index"
        class="infinite-list-item"
        v-show="item.evaluateContent !== ''"
      >
        <div class="left">
          <img
            :src="(item.evaluateAvatar !== '' ?  item.evaluateAvatar : require('../../assets/images/linux.jpg'))"
          />
          <div class="nickName">{{item.evaluateNickname}}</div>
        </div>
        <div class="right">
          <div class="score">
            <el-rate
              v-model="item.score"
              disabled
              show-score
              text-color="#ff9900"
              score-template="{value}"
            ></el-rate>
          </div>
          <div class="content">{{item.evaluateContent}}</div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'keOpencourseComment',
  data() {
    return {
      commentList: []
    }
  },
  mounted() {
    this.commentList = this.$store.state.courseSrc.courseSrc.evaluate.reverse()
  }
}
</script>

<style lang="stylus" scoped>
.ke-opencourse-comment {
  position: relative;
  width: 830px;
  height: 300px;

  .none-comment {
    text-align: center;
    line-height: 300px;
    color: #999999;
  }

  .wrapper {
    padding-left: 0;
    height: 300px;
    overflow: scroll;

    &::-webkit-scrollbar {
      width: 0px;
    }

    li {
      position: relative;
      list-style: none;
      overflow: hidden;
      height: 112px;
      box-sizing: border-box;
      padding: 20px 20px 20px 80px;
      border-bottom: 1px solid #dddddd;

      &:last-child {
        border-bottom: none;
      }

      .left {
        position: absolute;
        width: 80px;
        top: 20px;
        left: 0;
        text-align: center;
        font-size: 14px;
        color: #333333;

        img {
          width: 40px;
          height: 40px;
          border-radius: 50%;
        }
      }

      .right {
        .score {
          margin-top: 10px;
        }

        .content {
          min-height: 28px;
          margin-bottom: 10px;
          font-size: 14px;
          line-height: 1.5;
          color: #333333;
        }
      }
    }
  }
}
</style>
